#!/usr/bin/env python
from os import path
Import('build env module')

sources = Glob('*.cpp')

env.Append(CPPDEFINES = ('TITANIUM_NETWORK_API_EXPORT', 1))
build.add_thirdparty(env, 'poco')
build.add_thirdparty(env, 'curl')

if build.is_osx():
    env.Append(FRAMEWORKS=['SystemConfiguration'])
    sources+=Glob('mac/*.cpp')

if build.is_linux():
    sources+=Glob('linux/*.cpp')
    env.ParseConfig('pkg-config --libs --cflags gdk-2.0 dbus-glib-1')

if build.is_win32():
    env.Append(CCFLAGS=['/MD', '/DUNICODE', '/D_UNICODE'])
    env.Append(LIBS=['wsock32','ws2_32', 'ole32', 'comsuppw', 'wbemuuid'])
    env.Append(CPPDEFINES = ('WIN32_LEAN_AND_MEAN',1))
    sources += Glob("win/*.cpp")

# Copy the support files the module build directory
build.utils.LightWeightCopy(path.join(build.cwd(), 'support'), module.dir)
build.mark_build_target(env.SharedLibrary(
    path.join(module.dir, 'tinetworkmodule'), sources))
